home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
util
/
cdity
/
ModeProSrc.lha
/
Daemon
/
BAckdrop.c
next >
Wrap
C/C++ Source or Header
|
1998-10-02
|
4KB
|
169 lines
#include "MP.h"
//#include "MPobject.h"
#include <proto/datatypes.h>
#include <proto/layers.h>
#include <datatypes/datatypesclass.h>
#include <datatypes/datatypes.h>
#include <datatypes/pictureclass.h>
#include "backfill.h"
//#include "imagebackfill.h"
#define MPHOOK_OK 0
#define MPHOOK_WARN 1
#define MPHOOK_FAIL 2
//#define DEBUG_STACK
//#define DEBUG
#include <debug.h>
extern BOOL V39;
void FreeBackfill(struct Backfill *B);
struct Backfill
{
struct Node bf_Node; // uses ln_Type;
struct Screen *bf_Screen;
struct Hook *bf_Hook;
};
/*
struct Backdrop
{
struct Node bd_Node;
struct Screen *bd_Screen;
struct Window *bd_Window;
BOOL bd_Loaded;
struct BackFillOptions bd_BFOptions;
struct BackFillInfo bd_BFInfo;
};
*/
struct List BackdropList;
LONG AddBackdrop(struct Screen *Scr, struct DefaultNode *DN)
{
struct Backfill *b;
DEBUG_CODE(DKP("AddBackdrop Scr=%8lx DNode=%8lx\n",Scr,DN););
if(Scr && DN && V39)
{
if(DN->BackdropType)
{
if(b=AllocVec(sizeof(*b),MEMF_CLEAR|MEMF_PUBLIC))
{
b->bf_Node.ln_Type=DN->BackdropType;
b->bf_Screen=Scr;
DEBUG_CODE(DKP("BackdropType=%ld\n",b->bf_Node.ln_Type););
switch(DN->BackdropType)
{
case 1:
b->bf_Hook=Image_AllocBackfillHook(Scr,DN);
break;
case 2:
b->bf_Hook=RGB_AllocBackfillHook(Scr,DN);
break;
}
DEBUG_CODE(DKP("bf_Hook=%ld\n",b->bf_Hook););
if(b->bf_Hook)
{
struct Hook *oldhook;
struct Window *win;
Forbid();
oldhook=InstallLayerInfoHook(&Scr->LayerInfo,b->bf_Hook);
if(0==oldhook) // if no previous hook
{
AddHead(&BackdropList,(struct Node *)b);
DEBUG_CODE(DKP("Hook Installed\n"););
if(win=OpenWindowTags(0,WA_CustomScreen, Scr,
WA_Left ,0,
WA_Top ,0,
WA_Width ,Scr->Width,
WA_Height ,Scr->Height,
WA_Flags ,WFLG_BACKDROP|WFLG_BORDERLESS|WFLG_SIMPLE_REFRESH|WFLG_NOCAREREFRESH,
WA_BackFill ,0,
TAG_DONE))
{// refresh backdrop
CloseWindow(win);
}
Permit();
return(MPHOOK_OK);
}
DEBUG_CODE(DKP("Hook Failed\n"););
InstallLayerInfoHook(&Scr->LayerInfo,oldhook);
Permit();
}
FreeBackfill(b);
}
}
}
return(MPHOOK_FAIL);
}
void RemoveBackdrop(struct Screen *Scr)
{
struct Backfill *b;
DEBUG_CODE(DKP("RemoveBackdrop Scr=%8lx\n",Scr););
b=(struct Backfill *)BackdropList.lh_Head;
while(b->bf_Node.ln_Succ)
{
if(b->bf_Screen==Scr)
{
struct Backfill *b2;
DEBUG_CODE(DKP("Removing Backdrop %8lx\n",b););
InstallLayerInfoHook(&Scr->LayerInfo,0);
b2=(struct Backfill *)b->bf_Node.ln_Succ;
Remove((struct Node *)b);
FreeBackfill(b);
b=b2;
}
else
{
b=(struct Backfill *)b->bf_Node.ln_Succ;
}
}
}
void FreeBackfill(struct Backfill *B)
{
DEBUG_CODE(DKP("FreeBackfill %8lx\n",B););
if(B->bf_Hook)
{
switch(B->bf_Node.ln_Type)
{
case 1:// Image
Image_FreeBackfillHook(B->bf_Hook);
break;
case 2:// Color
RGB_FreeBackfillHook(B->bf_Hook);
break;
}
}
FreeVec(B);
}